package com.example.customvidewbyheroes;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.LinearGradient;
import android.graphics.Paint;
import android.graphics.Shader;
import android.util.AttributeSet;
import android.view.View;
import android.widget.TextView;

import androidx.annotation.Nullable;

public class CustomeTextView extends androidx.appcompat.widget.AppCompatTextView {

    private Paint mPaint1;
    private Paint mPaint2;
    public CustomeTextView(Context context) {
        super(context);
        initProperty();
    }

    public CustomeTextView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        initProperty();
    }

    public CustomeTextView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        initProperty();
    }


    private void initProperty(){
        mPaint1 = new Paint();
        mPaint1.setColor(getResources().getColor(android.R.color.holo_blue_bright));
        mPaint1.setStyle(Paint.Style.FILL);
        mPaint2 = new Paint();
        mPaint2.setColor(Color.YELLOW);
        mPaint2.setStyle(Paint.Style.FILL);

    }

    @Override
    protected void onDraw(Canvas canvas) {

        canvas.drawRect(0,0,
                getMeasuredWidth(),getMeasuredHeight(),mPaint1);
        canvas.drawRect(10,10,
                getMeasuredWidth()-10,getMeasuredHeight()-10,mPaint2);
        canvas.save();
        canvas.translate(10,10);
        super.onDraw(canvas);
        canvas.restore();
    }


}
